package cn.stu.system.controller;


import cn.stu.common.utils.R;
import cn.stu.framework.entity.SysListener;
import cn.stu.framework.service.ISysListenerService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 流程监听Controller
 *
 * @author Tony
 * @date 2022-12-25
 */
@RestController
@RequestMapping("/system/listener")
@AllArgsConstructor
public class SysListenerController {
    private ISysListenerService sysListenerService;

    /**
     * 查询流程监听列表
     */
    @GetMapping("/list")
    public R list(SysListener sysListener) {
        return sysListenerService.selectSysListenerList(sysListener);

    }

    /**
     * 导出流程监听列表
     */
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, SysListener sysListener)
//    {
//        List<SysListener> list = sysListenerService.selectSysListenerList(sysListener);
//        ExcelUtil<SysListener> util = new ExcelUtil<SysListener>(SysListener.class);
//        util.exportExcel(response, list, "流程监听数据");
//    }

    /**
     * 获取流程监听详细信息
     */
    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id) {
        return sysListenerService.selectSysListenerById(id);
    }

    /**
     * 新增流程监听
     */

    @PostMapping
    public R add(@RequestBody SysListener sysListener) {
        return sysListenerService.insertSysListener(sysListener);
    }

    /**
     * 修改流程监听
     */

    @PutMapping
    public R edit(@RequestBody SysListener sysListener) {
        return sysListenerService.updateSysListener(sysListener);
    }

    /**
     * 删除流程监听
     */

    @DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids) {
        return sysListenerService.deleteSysListenerByIds(ids);
    }
}
